/**   
 * @Title: FootballLotteryInfoCommunicater.java 
 * @Package: com.esun.rabbit2.communicaters.lotteryinfo 
 * @Description: (竞彩足球开奖信息接口) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-8-15 上午10:24:07  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.lotteryinfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.FootballLotteryInfoListInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.log.EDebug;

/**
 * @ClassName: FootballLotteryInfoCommunicater
 * @Description: (竞彩足球开奖信息接口)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-8-15 上午10:24:07
 */
public class FootballLotteryInfoCommunicater extends ServerCommunicater {

	private String msgServer;

	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	/**
	 * @throws SAXException
	 * @throws ParserConfigurationException
	 * @throws IOException
	 * @throws ClientProtocolException
	 * @Title: isGetCurrentLotInfo
	 * @Description: (获取竞彩足球开奖信息接口 业务编号10009)
	 * @param @return isSucceed
	 * @return boolean 返回类型
	 * @throws
	 */
	public boolean isGetFootballLotteryInfo(String date) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(Config.PASER_MID, BussinessCode.MID_FOOTBALL_LOTINFOLIST));
		list.add(mapItem(Config.PASER_CK, Config.NULLMARK));
		list.add(mapItem(Key.KEY_TIME, date));

		super.getServerResponse(list, true);
		if (super.getState() == 100) {
			isSucceed = true;
			if (super.getListResult().size() == 0) {
				EDebug.o("list 为空");
				isSucceed = false;
			} else {
				EDebug.o("list 不为空");
			}
		} else {
			isSucceed = false;
		}
		setMsgServer(super.getErrorMSG());
		return isSucceed;
	}

	// 保存竞彩足球开奖信息
	public ArrayList<FootballLotteryInfoListInfo> getFootballLotteryInfoList() {

		ArrayList<FootballLotteryInfoListInfo> returnList = new ArrayList<FootballLotteryInfoListInfo>();

		int count = super.getListResult().size();
		for (int i = 0; i < count; i++) {
			FootballLotteryInfoListInfo lotteryInfo = new FootballLotteryInfoListInfo();
			lotteryInfo.setMatchNumDate(super.getListResult().get(i).get(Key.KEY_MATCHNUMDATE));
			lotteryInfo.setDayOfWeek(super.getListResult().get(i).get(Key.KEY_DAYOFWEEK));
			lotteryInfo.setHomeTeam(super.getListResult().get(i).get(Key.KEY_HOMESXNAME));
			lotteryInfo.setRangQiu(super.getListResult().get(i).get(Key.KEY_RANGQIU));
			lotteryInfo.setScore(super.getListResult().get(i).get(Key.KEY_SCORE));
			lotteryInfo.setVisitingTeam(super.getListResult().get(i).get(Key.KEY_AWAYSXNAME));
			lotteryInfo.setState(super.getListResult().get(i).get(Key.KEY_STATE));
			lotteryInfo.setSimpleLeague(super.getListResult().get(i).get(Key.KEY_SIMPLELEAGUE));
			lotteryInfo.setMatchNum(super.getListResult().get(i).get(Key.KEY_GAMENUM));
			lotteryInfo.setHomeTeamImage(super.getListResult().get(i).get(Key.KEY_HOMESXNAMEID));
			lotteryInfo.setVisitTeamImage(super.getListResult().get(i).get(Key.KEY_AWAYSXNAMEID));

			returnList.add(lotteryInfo);
		}
		return returnList;
	}

	// 返回比赛场次列表
	public String getCountList() {
		return super.getResult().get(Key.KEY_GAMECOUNT);
	}

	// 返回比赛星期列表
	public String getWeekList() {
		return super.getResult().get(Key.KEY_DAYOFWEEK);
	}

	// 返回比赛日期列表
	public String getDateList() {
		return super.getResult().get(Key.KEY_DAYLIST);
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
